<?php 

namespace Home\Controller;
use Think\Controller;
use Home\Controller\CommonController;
class NnansweredController extends CommonController
{
    public function Nnanswered()
    {
        $uid  = I('get.uid');
        $sql="select * from question where answer_num='0' ";
        $list=M()->query($sql);
        // var_dump($list);
        $this->assign('list',$list);


        $count = M('question')->count();
        // var_dump($count);
        $Page  = new \Think\Page($count,4);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show  = $Page->show();// 分页显示输出


        //  $sql = "select t1.*,t2.username from question t1 inner join user t2 on t1.uid=t2.id order by t1.create_time desc limit $Page->firstRow,$Page->listRows";

        // $list = M()->query($sql);


        foreach ($list as &$row) {
            $row['categorys'] = $this->getCategory($row['id']);
        }
      
        $this->assign('list',$list);
        $this->assign('show',$show);
        $this->display();
    }

   
    public function getCategory($qid)
    {
        $sql = "select t2.id cid ,t2.cname from question_category t1 left join category t2 on t1.cid=t2.id where t1.qid='{$qid}'";
        return M()->query($sql);
    }

    
}

    
    

    




 ?>